﻿namespace GenricTypes;

public class SimpleTuple<T1,T2>
{
    public T1 Item1;
    public T2 Item2;

    public SimpleTuple(T1 item1,T2 item2)
    {
        Item1 = item1;
        Item2 = item2;
    }
    
    
    SimpleTuple<int,int> GetMinAndMax(IEnumerable<int> input)
    {
        if (!input.Any())
        {
            throw new InvalidOperationException($"The input collection cannot be empty.");
        }

        int min = input.First();
        int max = input.First();
        foreach (var item in input)
        {
            if (item > max)
                max = item;
            if (item < min)
                min = item;
        }

        return new SimpleTuple<int, int>(max, min);
    }

    Tuple<int,int> GetMinMax(IEnumerable<int> input)
    {
        if (!input.Any())
        {
            throw new InvalidOperationException($"The input collection cannot be empty.");
        }

        int min = input.First();
        int max = input.First();
        foreach (var item in input)
        {
            if (item > max)
                max = item;
            if (item < min)
                min = item;
        }

        return new Tuple<int, int>(max, min);
    }
}